package com.lujieni.netty.c3;

import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.util.NettyRuntime;
import io.netty.util.concurrent.Future;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

public class TestEventLoop {

    public static void main(String[] args) throws InterruptedException, ExecutionException {
        EventLoopGroup group = new NioEventLoopGroup(2); // io事件 普通任务 定时任务

        System.out.println(group.next());
        System.out.println(group.next());
        System.out.println(group.next());

        group.next().execute(()->{
            System.out.println("hello world");
        });


        Future<?> submit = group.next().submit(() -> {
            return "hello";
        });

        group.next().scheduleAtFixedRate(()->{
            System.out.println("ok");
        }, 0, 1, TimeUnit.SECONDS);


        Object o = submit.get();
        System.out.println(o);

       // Thread.currentThread().join();

    }
}
